#include "syscall.h"
int Lock[4];
int Condition[4];
void test3_main()
{
	WriteFormat("----------Test Case III---------\n",34,0,0);
	WriteFormat("/*Test Function of Distributed Condition */\n",45,0,0);

	WriteFormat("3-0 Prepare Lock to be used    \n",33,0,0);
	Lock[0] = RemoteCreateLock("TestConditionLock1",18);
	WriteFormat("    Lock Created, handle is %d \n",38,Lock,1);
	
	WriteFormat("3-1 CreateCondition            \n",33,0,0);
	Condition[0] = RemoteCreateCondition("TestCondition1",14);
	WriteFormat("    Condition Created, handle is %d \n",38,Lock,1);
	
	WriteFormat("3-2 Wait and Signal Condition  \n",33,0,0);
	RemoteAcquireLock(Lock[0]);
	WriteFormat("    Lock Acquired, handle is %d\n",33,Lock,1);
	WriteFormat("    Wait for another client to Signal Me Up later \n",52,0,0);
	WriteFormat("    Main thread is waiting!!   \n",33,0,0);
	RemoteWaitCondition(Condition[0],Lock[0]);
	WriteFormat("    Main thread is Waken Up by client 2\n",41,0,0);
	RemoteReleaseLock(Lock[0]);
	RemoteDestroyLock(Lock[0]);
	RemoteDestroyCondition(Condition[0]);
	WriteFormat("------------test end-----------\n",33,0,0);
	return;
}

int main()
{
	test3_main();
}
